//
//  OrderDetailViewController.m
//  XDCommonApp
//
//  Created by xindao on 14-7-3.
//  Copyright (c) 2014年 XD-XY. All rights reserved.
//

#import "OrderDetailViewController.h"
#import "QRCodeGenerator.h"
#import "UIImageView+WebCache.h"
@interface OrderDetailViewController ()

@end

@implementation OrderDetailViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.titleLabel.text = @"订单详情";

    int height = 0;
    if (IOS7) {
        height = 20;
    }

    UIImageView * shareIV = [[UIImageView alloc] initWithFrame:CGRectMake(285, height+10, 25, 25)];
    shareIV.image = [UIImage imageNamed:@"shareBtn_img"];
    [self.navigationBarView addSubview:shareIV];

    [XDTools getAButtonForView:self.navigationBarView frame:CGRectMake(270, height, 50, 44) nomalTitle:nil hlTitle:nil titleColor:nil bgColor:[UIColor clearColor] nbgImage:nil hbgImage:nil action:@selector(shareBtnClick) target:self buttonTpye:UIButtonTypeCustom];

    backScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, UI_MAINSCREEN_HEIGHT - UI_NAVIGATION_BAR_HEIGHT)];
    backScrollView.delegate = self;
    backScrollView.contentSize = CGSizeMake(UI_SCREEN_WIDTH, 515);
    backScrollView.pagingEnabled = NO;
    [self.contentView addSubview:backScrollView];

    NSString * userID = [[NSUserDefaults standardUserDefaults] objectForKey:kMMyUserInfo][0];
    NSString * codeStr = [NSString stringWithFormat:@"%@|%@|%@",_shop_price,_timeStr,userID];

    codeIV = [[UIImageView alloc] initWithFrame:CGRectMake(45, 374/2.0f, 230, 230)];
    codeIV.image = [QRCodeGenerator qrImageForString:codeStr imageSize:codeIV.bounds.size.width];
    codeIV.layer.borderColor = [UIColor lightGrayColor].CGColor;
    codeIV.layer.borderWidth = 1;
    [backScrollView addSubview:codeIV];

    headIV = [[UIImageView alloc] initWithFrame:CGRectMake(15, 30, 70, 70)];
    [headIV setImageWithURL:[NSURL URLWithString:_goods_img] placeholderImage:nil];
    [backScrollView addSubview:headIV];

    [XDTools addAlabelForAView:backScrollView withText:@"订单号:" frame:CGRectMake(97, 28, 85, 20) font:[UIFont systemFontOfSize:16] textColor:[UIColor blackColor]];
    [XDTools addAlabelForAView:backScrollView withText:@"交易金额:" frame:CGRectMake(97, 58, 85, 20) font:[UIFont systemFontOfSize:16] textColor:[UIColor blackColor]];
    [XDTools addAlabelForAView:backScrollView withText:@"付款方式:" frame:CGRectMake(97, 88, 85, 20) font:[UIFont systemFontOfSize:16] textColor:[UIColor blackColor]];
    numberLB = [XDTools addAlabelForAView:backScrollView withText:_timeStr frame:CGRectMake(190, 28, 100, 20) font:[UIFont systemFontOfSize:16] textColor:[UIColor blackColor]];
    payNumberLB = [XDTools addAlabelForAView:backScrollView withText:[NSString stringWithFormat:@"%.2f",[_shop_price floatValue]/100] frame:CGRectMake(190, 58, 100, 20) font:[UIFont systemFontOfSize:16] textColor:RGBA(245, 170, 87, 1)];
    UILabel * label = [XDTools addAlabelForAView:backScrollView withText:@"喵贷信用支付" frame:CGRectMake(190, 88, 100, 20) font:[UIFont systemFontOfSize:16] textColor:[UIColor blackColor]];
    numberLB.textAlignment = NSTextAlignmentRight;
    payNumberLB.textAlignment = NSTextAlignmentRight;
    label.textAlignment = NSTextAlignmentRight;

    timeLB = [XDTools addAlabelForAView:backScrollView withText:[NSString stringWithFormat:@"订单时间:%@",_addTime] frame:CGRectMake(15, 120, 150, 20) font:[UIFont systemFontOfSize:15] textColor:[UIColor darkGrayColor]];

    UIImageView * lineIV = [[UIImageView alloc] initWithFrame:CGRectMake(0, height_y(timeLB)+20, 320, .5f)];
    lineIV.image = [UIImage imageNamed:@"line"];
    [backScrollView addSubview:lineIV];

    self.shareView = [[XDShareView alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT)];
    _shareView.delegate = self;
    [self.view addSubview:_shareView];
}

#pragma mark ================分享按钮点击===================
-(void)shareBtnClick
{
    [_shareView setViewShow];
    DDLOG_CURRENT_METHOD;
}

#pragma mark ===============xdshareview delegate==========
-(void)shareViewBtnCLick:(UIButton *)button
{
    if (button.tag == 1001){
        [[UMSocialControllerService defaultControllerService] setShareText:@"我刚刚使用“喵贷”，得到了我朝思暮想的ta！你也一起来试试吧！喵贷，青春专属信贷应用，一次购物分期支付，无需抵押，不用证明，只要拿出诚意、亮出诚信，你和你的梦想只有一个app的距离！点击链接极速下载：" shareImage:[UIImage imageNamed:@"Icon"] socialUIDelegate:self];
        [UMSocialData defaultData].extConfig.title = @"喵贷信用支付";
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
    }else{
        //朋友圈分享
        [[UMSocialControllerService defaultControllerService] setShareText:@"我刚刚使用“喵贷”，得到了我朝思暮想的ta！你也一起来试试吧！喵贷，青春专属信贷应用，一次购物分期支付，无需抵押，不用证明，只要拿出诚意、亮出诚信，你和你的梦想只有一个app的距离！点击链接极速下载：" shareImage:[UIImage imageNamed:@"Icon"] socialUIDelegate:self];
        [UMSocialData defaultData].extConfig.title = @"喵贷信用支付";
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatTimeline].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
